/**
 * @class   wosh::gui::WidgetBuildingRenderer
 * @brief   
 *          
 *          
 *
 ****************************************************************************
 * @version $Id: WidgetBuildingRenderer.h 2891 2010-08-12 01:58:59Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Gui_WidgetBuildingRenderer_H__
 #define __WOSH_Gui_WidgetBuildingRenderer_H__

 #include <framework/gui/IWidget.h>
 #include <QtGui/QTextEdit>
 #include <QtGui/QMenu>
 #include <core/Containers.h>
 #include <framework/gui/components/BusConnectorQt.h>
 #include <framework/gui/BuildingObjectGraphicsItem.h>

namespace Ui {
 class WidgetBuildingRenderer;
};
namespace wosh {
 namespace gui {



class WidgetBuildingRenderer :	public IWidgetGeneric,
								public virtual IBusListener,
								public virtual IBuildingObjectGraphicsItemListener
 {
	Q_OBJECT

	public:
		WidgetBuildingRenderer(QWidget *parent = 0);
		virtual ~WidgetBuildingRenderer();

	public:
		WRESULT updateObject( const wosh::building::BuildingObject* bobj );
		WRESULT renderObject( const std::string& bobj_name );

		BuildingObjectGraphicsItem* createGraphicsItemFor( const wosh::building::BuildingObject* bobj );


	public slots:
		void refreshAll();
		void refreshCombos();

	public:
		void busMessage( const Message& message, const Bus* source );
		void item_event( Message* message, BuildingObjectGraphicsItem* source );

	protected slots:
		void gArea_zoomIn();
		void gArea_zoomOut();
		void gArea_rotateLeft();
		void gArea_rotateRight();
		void gArea_save();
		void gArea_setupMatrix();
		void gArea_reset();
		void gArea_option_triggered( QAction* action );

	protected slots:
		void render_item( const QString& text );

	protected:
		QList<BuildingObjectGraphicsItem*> getItemsByType( const std::string& itemType );
		QStringList getItemsNameByType( const std::string& itemType );

	protected:
		void changeEvent(QEvent *e);

	protected:
		QAction* actItemsMoveable;
		QAction* actItemsVisible;

	protected:
		MapT<std::string, BuildingObjectGraphicsItem*> items;

	private:
		Ui::WidgetBuildingRenderer *m_ui;

		BusConnectorQt BusBuilding;


}; // class def

 }; // namespace gui
}; // namespace wosh


#endif // __WOSH_Gui_WidgetBuildingRenderer_H__